<?php


session_start();

 

if(!isset($_SESSION['admin']) && $_SESSION['admin']!=1){
    
    header('HTTP/1.1 500 Internal Server Error');
}



include('db.php');

$w['zt'] = 1;

$lists = Db::table('newpos')->where($w)->order(' id desc')->select();


if(isset($_REQUEST['act']) &&  $_REQUEST['act'] == 'dele'){
    
   $id = $_REQUEST['id'];
   
 
   
   $dd['id'] = $id;
   $up['zt'] = 0;
   Db::table('newpos')->where($dd)->update($up);
   
   $sql = "delete from  newpos_data where pos_id = ".$id;
   
   
   Db::dels($sql);
   

   
   header("location: /list.php");
} 

?>


<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>POS定时下单列表 </title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="./News/layui/css/layui.css"  media="all">
  <style>
      
      .ahk{
          
            display: inline-block;
            margin: 0px 0px 5px 5px;
            padding: 4px 8px;
            font-size: 14px;
            outline: none;
            text-align: center;
            width: 50px;
            line-height: 24px;
            cursor: pointer;
            color: #ccc;
            border: solid 1px #ccc;
      }
      
      .ahks{
           display: inline-block;
            margin: 0px 0px 5px 5px;
            padding: 4px 8px;
            font-size: 14px;
            outline: none;
            text-align: center;
            width: 50px;
            line-height: 24px;
            cursor: pointer;
          color: #fff;
          background: red;
      }
      .layui-form input[type=checkbox], .layui-form input[type=radio], .layui-form select {
    display: unset;
    width: 30px;
    height: 30px;
}
      
  </style>
</head>
<body>
 
<div style="width:95%; padding:10px">
    
         
 
 
     
     
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
      <legend>下单日志</legend>
    </fieldset>
    
    
    
     <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
              
                	<tr>
                	    <th>店铺</th>
                	    <th>下单时间范围</th>
                	    <th>随机间隔</th>
                	    <th>总订数</th>
                	    <th>创建时间</th>
                	    <th>状态</th>
                	    <th>操作</th>
                	</tr>
                	
    
                	<?php foreach ($lists as $k => $v): ?>
                
                		<tr>
                			<td>
                				 <?=$v['seller_name']?> 
                			</td>
                			<td>
                			  	 <p>开始时间：<?=date('Y-m-d H:i:s',$v['date'])?> </p> 
                			  	 
                			  	 <p>结束时间：<?=date('Y-m-d H:i:s',$v['date1s'])?> </p> 
                			</td>
                			<td >
                			 	 <p> <?=$v['time']?>- <?=$v['time2']?>分钟</p> 
                			  	  
                			</td>
                	     	 <td>
                	     	    <p>总单数：  <?=$v['dnum']?>  </p>
                	     	    <p>已下单：  <?=$v['snum']?>  </p>
                			</td>
                			 <td>
                	     	     <?=date('Y-m-d H:i:s',$v['addtime'])?> 
                			</td>
                			
                			 <td>
                	     	      <?php if((time() > $v['date']  && time() < $v['date1s']) && ($v['dnum'] != $v['snum'])){ ?>
                	     	      
                	     	       <span style="color:red">进行中</span>
                	     	      
                	     	      <?php }elseif( (time() > $v['date']  && time() > $v['date1s']) || ($v['dnum'] == $v['snum'])){ ?>
                	     	      
                	     	      <span style="color:#ccc">已结束</span>
                	     	       
                	     	      
                	     	      <?php }else { ?>
                	     	      <span>等待开始</span>
                	     	      <?php } ?>
                			</td>
                			
                			<td>
                 
                			   <span class="base">
                			   
                			   <a class="ahk"   href="?act=dele&id=<?=$v['id']?>"     > 删除 </a>
                			   
                			   </span>
                			   
                			   
                			</td>
                		</tr>
                
                	<?php endforeach; ?>
                	
            
                	 
                	
                </table>
    
    
    
 </div>
 

</body>
</html>